<!doctype html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>司法厅退回监狱 - 再次发起核查</title>
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css"/>
    <script src="/static/js/common/common.js" type="text/javascript"></script>
    <link href="/webjars/miniui/css/demo.css" rel="stylesheet" type="text/css"/>
    <link href="/static/css/default.css" rel="stylesheet" type="text/css"/>
    <style>
        table {
            border-collapse: separate;
        }
        .discell{
            text-align: right;
            width: 120px;
        }
    </style>
</head>
<body>
<form id="form1" method="post" style="height:90%;width: 100%;overflow-x: auto;overflow-y: auto;">
    <div>
        <table class="form-table" align="center">
            <tr>
                <td class="discell">服刑人员姓名:</td>
                <td >
                    <input name="pname" id="pname" class="mini-textbox" value="${pname!''}" style="width: 100%" readonly/>
                </td>

                <td class="discell">性别:</td>
                <td >
                    <input name="sex" id="sex" class="mini-textbox" value="${sex!''}" style="width: 100%" readonly/>
                </td>
            </tr>
            <tr>
                <td class="discell">
                    发起核查地址:
                </td>
                <td colspan="4" >
                    <input id="nativepro" name="nativepro" class="mini-combobox" required="true" emptyText="省份"
                           style="width:150px;"
                           textfield="codeName" valueField="codeId"
                           onclick="onDeptChanged('nativepro')" onvaluechanged="onValueChanged('nativepro')"/>
                    <input id="nativecity" name="nativecity" class="mini-combobox" required="true" emptyText="市"
                           style="width: 110px"
                           textfield="codeName" valueField="codeId" onclick="onDeptChanged('nativecity')"
                           onvaluechanged="onValueChanged('nativecity')"/>
                    <input id="nativecou" name="nativecou" class="mini-combobox" required="true" emptyText="县"
                           style="width: 110px"
                           textfield="codeName" valueField="codeId" onclick="onDeptChanged('nativecou')"
                           onvaluechanged="onValueChanged('nativecou')"/>
                    <input id="nativevill" name="nativevill" class="mini-combobox" emptyText="街道" style="width: 130px"
                           textfield="codeName" valueField="codeId"onclick="onDeptChanged('nativevill')" showNullItem="true" required="false"/>
                </td>
            </tr>
            <tr>
                <td class="discell"></td>
                <td colspan="4" style="width: 500px;">
                    <input class="mini-textbox" required="true" style="width: 510px" emptyText="详细地址" id="nativenum"
                           name="nativenum"/>
                </td>
            </tr>
            <tr>
                <td class="discell">刑期起日:</td>
                <td >
                    <input name="rjDate" id="rjDate" class="mini-textbox" value="${rjDate!''}" style="width: 100%" readonly/>
                </td>

                <td class="discell">刑期止日:</td>
                <td >
                    <input name="cjDate" id="cjDate" class="mini-textbox" value="${cjDate!''}" style="width: 100%" readonly/>
                </td>
            </tr>
            <#if sftsbyy?? && sftsbyy != null>
                <tr>
                    <td class="discell">司法厅备注:</td>
                    <td >
                        <input name="sftsbyy" id="sftsbyy" class="mini-textbox" value="${sftsbyy!''}" style="width: 100%" readonly/>
                    </td>
                </tr>
            </#if>
            <tr>
                <td class="discell"><font color="#dc143c">*</font>发起核查人员姓名:</td>
                <td >
                    <input name="startCheckPerson" id="startCheckPerson" class="mini-textbox" value="${startCheckPerson!''}" style="width: 100%" required="true"/>
                </td>
                <td class="discell"><font color="#dc143c">*</font>发起核查时间:</td>
                <td >
                    <input name="startCheckTime" id="startCheckTime" class="mini-datepicker" nullValue="null" format="yyyy-MM-dd H:mm:ss"
                           timeFormat="H:mm:ss" showTime="true"
                           showOkButton="true" enabled="false" showClearButton="false" allowInput="true" value="${startCheckTime!''}"
                           style="width: 100%" required="true" />
                </td>
            </tr>
            <tr>
                <td class="discell">发起核查人员固话:</td>
                <td >
                    <input name="startCheckTel" id="startCheckTel" class="mini-textbox" value="${startCheckTel!''}" style="width: 100%"
                           emptyText="请输入固定电话" onvaluechanged="checkPhone(1)"/>
                </td>
                <td class="discell">发起核查人员手机:</td>
                <td >
                    <input name="startCheckPhone" id="startCheckPhone" class="mini-textbox" value="${startCheckPhone!''}" style="width: 100%"
                           emptyText="请输入手机号码" onvaluechanged="checkPhone(2)"/>
                </td>
            </tr>
        </table>
    </div>
    <div style="padding:5px;margin: 0 auto;text-align: center">
        <a class="mini-button" iconCls="fa-save" plain="true" style="font-size: 15px"
           onclick="saveData()">确认发起</a>
    </div>
</form>
<script type="text/javascript">
    mini.parse();
    var form = new mini.Form("form1");
    var nativepro = mini.get("nativepro");
    var nativecity = mini.get("nativecity");
    var nativecou = mini.get("nativecou");
    var nativevill = mini.get("nativevill");
    var nativenum = mini.get("nativenum");
    var startCheckPerson = mini.get("startCheckPerson");
    var startCheckTime = mini.get("startCheckTime");
    var startCheckTel = mini.get("startCheckTel");
    var startCheckPhone = mini.get("startCheckPhone");
    var sftsbyy = mini.get("sftsbyy");
    var time='${startCheckTime}';
    var failurenum = '${failurenum!''}';

    window.onload = function () {
        mini.get("rjDate").setEnabled(false);
        mini.get("cjDate").setEnabled(false);
        mini.get("pname").setEnabled(false);
        mini.get("sex").setEnabled(false);
        mini.get("sftsbyy").setEnabled(false);
    }

    function SetData(data) {
        var o = mini.decode(data);
        nativepro.setData([{"codeId": data.nativepro, "codeName": data.nativeproName}]);
        nativecity.setData([{"codeId": data.nativecity, "codeName": data.nativecityName}]);
        nativecou.setData([{"codeId": data.nativecou, "codeName": data.nativecouName}]);
        nativevill.setData([{"codeId": data.nativevill, "codeName": data.nativevillName}]);
        form.setData(o);
        startCheckPerson.setValue('${startCheckPerson!''}');
        startCheckPhone.setValue('${startCheckPhone!''}')
        startCheckTime.setValue(time)
        startCheckTel.setValue('${startCheckTel!''}');
        nativenum.setValue(data.nativenum);
        sftsbyy.setValue('${sftsbyy}');
    }

    function saveData(state) {
        form.validate();
        if (form.isValid() == false) {
            return;
        }
        //校验电话与固话必须输入一个
        var phone = startCheckPhone.getValue();
        var telPhone = startCheckTel.getValue();
        var newPhone = checkTelAndPhone(telPhone,phone);
        var flag = newPhone['flag'];
        var kflag = newPhone['kflag'];
        if ('-1' === kflag) {
            mini.alert("请至少输入一个联系方式");
            return;
        }
        if (flag) {
        } else {
            mini.alert("手机号码或固话有误，请重填");
            return;
        }
        var data = form.getData();
        data.nativeproName = nativepro.getText();
        data.nativecityName = nativecity.getText();
        data.nativecouName = nativecou.getText();
        data.nativevillName = nativevill.getText();
        data.priNum = '${prinum!''}';
        var json = mini.encode(data);
        commonSaveData("/azbj/verification/agreestate", {
            data: json
        }, callback);
        // 保存成功的回调函数
        function callback() {
            mini.alert("保存成功","成功",window.CloseOwnerWindow);
        }
    }
    /**
     * 户籍地址
     * @param e
     */
    var urltemp = "/azbj/getCodeDetail/?codeType=2_1&codeId=-2";
    function onDeptChanged(e) {
        if ("nativepro" == e) {
            var value = nativepro.getValue();
            nativepro.setValue("");
            var url = "/azbj/getCodeDetail/?codeType=2_1&codeId=-1";
            nativepro.setUrl(url);
            if(value!=''){
                nativepro.setValue(value);
            } else {
                nativepro.select(0);
            }
        }
        if ("nativecity" == e) {
            var value = nativecity.getValue();

            if(nativepro.getValue()==""){
                nativepro.setUrl(urltemp);
                nativepro.setValue("");
                nativecou.setUrl(urltemp);
                nativecou.setValue("");
                nativevill.setUrl(urltemp);
                nativevill.setValue("");
                return;
            }
            var codeId = nativepro.getValue();
            nativecity.setValue("");
            var url = "/azbj/getCodeDetail/?codeType=2_1&codeId=" + codeId;
            nativecity.setUrl(url);
            if(value!=''){
                nativecity.setValue(value);
            } else {
                nativecity.select(0);
            }
        }

        if ("nativecou" == e) {
            var value = nativecou.getValue();

            if(nativecity.getValue()==""){
                nativecou.setUrl(urltemp);
                nativecou.setValue("");
                nativevill.setUrl(urltemp);
                nativevill.setValue("");
                return;
            }
            var codeId = nativecity.getValue();
            nativecou.setValue("");
            var url = "/azbj/getCodeDetail/?codeType=2_1&codeId=" + codeId;
            nativecou.setUrl(url);
            if(value!=''){
                nativecou.setValue(value);
            } else {
                nativecou.select(0);
            }
        }

        if ("nativevill" == e) {
            var value = nativevill.getValue();

            if(nativecou.getValue()==""){
                nativevill.setUrl(urltemp);
                nativevill.setValue("");
                return;
            }
            var parent_code = nativecou.getValue();
            nativevill.setValue("");
            var url = "/azbj/getCodeDetail?codeType=2_1&codeId=" + parent_code;
            nativevill.setUrl(url);
            if(value!=''){
                nativevill.setValue(value);
            } else {
                nativevill.select(0);
            }
        }
    }

    function onValueChanged(e) {
        if ("nativepro" == e) {
            nativecity.setValue("");
            nativecou.setValue("");
            nativevill.setValue("");
        }

        if ("nativecity" == e) {
            nativecou.setValue("");
            nativevill.setValue("");
        }

        if ("nativecou" == e) {
            nativevill.setValue("");
        }
    }

    function checkPhone(e){
        var startCheckPhone = mini.get("startCheckPhone").getValue();
        var startCheckTel = mini.get("startCheckTel").getValue();
        if (e == '1') {
            if(startCheckTel != '' && !validateTel(startCheckTel)) {
                mini.alert("固定电话有误，请重填");
            }
        }
        if (e == '2') {
            if(startCheckPhone != '' && !validatePhone1(startCheckPhone)) {
                mini.alert("手机号码有误，请重填");
            }
        }
    }
</script>
</body>
</html>